

/**
 * 
 * @author meranermarcel
 *	
 *	Class which represents the speed of the robot
 */

public final class Speed {
	private int left = 0;
	private int right = 0;
	
	//maximale Werte die es dem Robotor noch ermöglichen im Stand zu drehen.
	private static int MIN_SPEED = -1000; 
	private static int MAX_SPEED = 1000; 
	
	public Speed(int left, int right) throws SetSpeedException {
		setLeft(left);
		setRight(right);
	}

	public int getLeft() {
		return this.left;
	}

	public void setLeft(int left) throws SetSpeedException {
		checkSpeed(left);
		this.left = left;
	}

	public double getRight() {
		return this.right;
	}

	public void setRight(int right) throws SetSpeedException {
		checkSpeed(right);
		this.right = right;
	}
	
	private void checkSpeed(int speed) throws SetSpeedException{
		if(speed > MAX_SPEED || speed < MIN_SPEED ){
			throw new SetSpeedException("Speed cannot be set to a speed lower then minus 1000 and heiger then plus 1000");
		}
	}

}
